<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/store/include/init_store.jsp" %>
<%

	if (!isSeller) {
		response.sendRedirect("/");
		return ;
	}



	HashList code010		= CommonUtil.getCodeList("010");	//무료구분
	HashList codeCategory	= CommonUtil.getCodeList("category");	//카테고리
	
	String book_code	= StringUtil.nvl(request.getParameter("book_code"));
	String job_type		= "".equals(book_code) ? "C" : "U";
	
	HashMap infos = new HashMap();
	infos.put("publisher_id", session_user_id);
	infos.put("book_code", book_code);
	
	PublisherDAO dao = new PublisherDAO();
	HashList list 	= dao.selectBookInfo(infos);
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= HOME_NAME %></title>
	<%@ include file="/home/include/cssnjs.jsp"  %>
	<link rel="stylesheet" type="text/css" href="../../css/smoothness/jquery-ui-1.8.17.custom.css" media="screen" />
	<script type="text/javascript" src="../../js/jquery-ui-1.8.18.custom.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../js/jquery.maskedinput-1.3.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../js/jquery.ui.datepicker-ko.js" charset="utf-8"></script>
	<script type="text/javascript" src="/SE2.3.1.O9858/js/HuskyEZCreator.js" charset="utf-8"></script>
	<script type="text/javascript">
	var oEditors = [];
	$(document).ready(function() {
		$('#store_main li:nth-child(2)').addClass('on');
		$('#publish_dt').mask('9999.99.99').datepicker();

		cfInitSE("intro");
		cfInitSE("index_info");
		cfInitSE("author_info");
		

	});

	function fnSave() {
		if (confirm(MSG_<%=job_type%>)) 
		{
			if ('<%= job_type %>' == 'C') {
				document.saveForm.book_code.value = '<%=session_user_id%>' + document.saveForm.book_seq.value;
			}
			oEditors.getById["intro"].exec("UPDATE_CONTENTS_FIELD", []);
			oEditors.getById["index_info"].exec("UPDATE_CONTENTS_FIELD", []);
			oEditors.getById["author_info"].exec("UPDATE_CONTENTS_FIELD", []);
			
			$('#saveForm').attr('action', './publisherBookSave.do');
			$('#saveForm').submit();
		}
	}
	</script>
</head>
<body>
<div id="wrap">
	<%@ include file="/publisher/include/header.jsp"  %>
	<div id="contents">
		<h2>큐북관리</h2>
		

		<form id="saveForm" name="saveForm" enctype="multipart/form-data"  method="post" action="">
		<input type="hidden" name="job_type" id="job_type" value="<%= job_type %>"/>
		<input type="hidden" name="seller_id" value="<%= session_user_id %>"/>
		
		<div class="mt10 r">
	<%	if ("U".equals(job_type)) { %>
			<a href="./bookList.jsp"><img src="./images/btn_list.gif"/></a>
			<a href="#nohref" onclick="fnSave()"><img src="./images/btn_save.gif"/></a>
			<a href="#nohref" onclick="fnDelete()"><img src="./images/btn_delete.gif"/></a>
	<%	} else if ("C".equals(job_type)) { %>
			<a href="#nohref" onclick="fnSave()"><img src="./images/btn_register.gif"/></a>
			<a href="./bookList.jsp"><img src="./images/btn_cancel.gif"/></a>
	<%	} %>
		</div>
		
		
		<div id="tabs-1" class="mt10">

			<table cellpadding="0" cellspacing="0" class="table_01 mt5">
			<colgroup>
				<col width="100px"/>
				<col width="200px"/>
				<col width="100px"/>
				<col width="200px"/>
				<col width="100px"/>
				<col/>
			</colgroup>
			<tbody>
				<tr>
					<th>큐북코드</th>
					<td>
						<input type="hidden" name="book_code" value="<%= list.get("book_code", 0) %>" />
					<% if ("C".equals(job_type)) { %>
						<input type="text" class="text" name="book_seller" size="12" maxlength="12" disabled="disabled" value="<%= session_user_id %>" />
						<input type="text" class="text" name="book_seq" size="4" maxlength="4"  value="" />
					<% } else { %>
						<%= list.get("book_code",0) %>
					<% } %>
					</td>
					<th>판매상태</th>
					<td >
						<%= list.get("sales_status", 0) %>
					</td>
					<th>서비스기간</th>
					<td>
						<%= list.getDate("start_dt", 0) %>  ~ <%= list.getDate("end_dt", 0) %>
					</td>
				</tr>
				<tr>
					<th>큐북명</th>
					<td colspan="5">
						<input type="text" class="text wmax" name="book_name" value="<%= list.get("book_name", 0) %>"  />
					</td>
				</tr>
				<tr>
					<th>소제목</th>
					<td colspan="5">
						<input type="text" class="text wmax" name="sub_title" value="<%= list.get("sub_title", 0) %>"  />
					</td>
				</tr>
				<tr>
					<th rowspan="8"><p>표지이미지</th>
					<td rowspan="8" >
						<input type="file" name="book_image_url" value="" class="input_file wmax" />
						<div class="mt5">
		        		<a href="<%= list.get("book_image_url",0) %>" target="_blank"><img src="<%= list.get("book_image_url",0) %>" width="160px"/></a>
		        		</div>
					</td>
				</tr>
				<tr>
					<th>출판사명</th>
					<td>
						<input type="text" class="text wmax" name="publisher_name" value="<%= list.get("publisher_name",0) %>" />
        			</td>
					<th>발행일</th>
					<td>
						<input type="text" class="text" name="publish_dt" id="publish_dt" value="<%= list.get("publish_dt", 0) %>"  class="w90 c"/>
        			</td>
        		</tr>
				<tr>
					<th>카테고리</th>
					<td>
						<select name="category_code">
						<%= StringUtil.makeOptionByGroup(codeCategory, list.get("category_code", 0)) %>
						</select>
        			</td>
					<th>저자명</th>
					<td>
						<input type="text" class="text wmax" name="author_name" value="<%= list.get("author_name", 0) %>"  />
        			</td>
        		</tr>
        		<tr>
					<th>페이지수</th>
					<td>
						<input type="text" class="text w60 r" name="page_count" value="<%= list.get("page_count", 0) %>"/> 페이지
        			</td>
					<th>용량</th>
					<td>
						<%= list.get("file_size", 0) %>
        			</td>
        		</tr>
        		<tr>
					<th>판매가</th>
					<td>
						<input type="text" class="text w60 r" name="price" value="<%= list.get("price", 0) %>"/> 원
					</td>
					<th>판매가(아이폰)</th>
					<td>
						<input type="text" class="text w60 r" name="price_usd" value="<%= list.get("price_usd", 0) %>"/> $
					</td>
				</tr>
        		<tr>
					<th>ISBN</th>
					<td>
						<input type="text" class="text wmax" name="isbn" value="<%= list.get("isbn", 0) %>"  />
        			</td>
					<th>ECN</th>
					<td>
						<input type="text" class="text wmax" name="ecn" value="<%= list.get("ecn", 0) %>"  />
        			</td>
				</tr>
				<tr>
					<th>큐북파일</th>
					<td colspan="3" >
						<input type="file" name="book_path_org" value="" class="input_file w200" />
					<%	if (!"".equals(list.get("book_path_org",0))) { %>
		        			<a href="/common/download_view.jsp?file_dir=<%= list.get("book_path_org",0) %>"><%= list.get("book_path_org",0) %></a>
					<%	} %>			        			
					</td>
				</tr>
				<tr>
					<th>미리보기파일</th>
					<td colspan="3">
						<input type="file" name="book_path_preview" value="" class="input_file w200" />
					<%	if (!"".equals(list.get("preview_book_path",0))) { %>
		        			<a href="/common/download_view.jsp?file_dir=<%= list.get("preview_book_path",0) %>"><%= list.get("preview_book_path",0) %></a>
					<%	} %>			        			
					</td>
				</tr>
        		<tr>
        			<th>책소개</th>
					<td colspan="5">
						<textarea name="intro" id="intro" style="width:100%; height:300px"><%= list.get("intro", 0) %></textarea>
					</td>
				</tr>
        		<tr>
        			<th>목차</th>
					<td colspan="5">
						<textarea name="index_info" id="index_info" style="width:100%; height:300px"><%= list.get("index_info", 0) %></textarea>
					</td>
				</tr>
        		<tr>
        			<th>저자소개</th>
					<td colspan="5">
						<textarea name="author_info" id="author_info" style="width:100%; height:300px"><%= list.get("author_info", 0) %></textarea>
					</td>
				</tr>
			</tbody>
			</table>

		</div>




		<div class="mt20 c">
	<%	if ("U".equals(job_type)) { %>
			<a href="./bookList.jsp"><img src="./images/btn_list.gif"/></a>
			<a href="#nohref" onclick="fnSave()"><img src="./images/btn_save.gif"/></a>
			<a href="#nohref" onclick="fnDelete()"><img src="./images/btn_delete.gif"/></a>
	<%	} else if ("C".equals(job_type)) { %>
			<a href="#nohref" onclick="fnSave()"><img src="./images/btn_register.gif"/></a>
			<a href="./bookList.jsp"><img src="./images/btn_cancel.gif"/></a>
	<%	} %>
		</div>


		</form>
	

	</div>
		
		<%@ include file="/publisher/include/footer.jsp"  %>	
</div>
</body>
</html>
